<?php
/**
 * 
 * 
 * 
 * Find the current active subscription, and give some details on it.
 * note: only one subscription can be active at any time.
 * 
 */
foreach( $subs as $sub ) {
    if ( $sub->status == 'inactive' && count($subs) > 1 ) continue;
?> 
           
<div id="subscription-summary" class="group <?php echo $sub->get_status(); ?>">
    <div class="left">
        <h1>
            
            <?php echo $user->displayname(); ?>
            &nbsp;&nbsp;
            <small>
            <?php
            switch( $sub->get_status( $raw = true ) ){
                case 'active':
                case 'expiring':
                case 'paused':
                    echo '(ISSUE ' .$sub->get_current_week() . " of " . $sub->subscription_length().')';
                    break;
                case 'inactive':
                    echo null;
                    break;
                case 'future':
                    echo '(ISSUE 0 of ' . $sub->subscription_length().')';
                    break;
            }
            ?>
            </small>
             <?php  ?>
        </h1>
        
        <?php
            switch( $sub->get_status( $raw = true ) ){
                case 'active':
                case 'expiring':
                case 'paused':
                    ?>
                    <div class="percent-bar"><span data-percent="<?php echo $sub->get_percent(); ?>"></span></div>
                    <?php
                    break;
            }
            ?>
        
        
        
         <p><?php echo $user->displayname();
            switch( $sub->get_status( $raw = true ) ){
                case 'active':
                    echo ' is <strong>ACTIVE</strong>. They are eligible to receive their issue for ' .  date('l, F jS, Y ', get_date_from_weeknum(get_weeknum()));
                    break;
                case 'expiring':
                    echo ' is <strong>EXPIRING</strong>. They are eligible to receive their issue for ' .  date('l, F jS, Y ', get_date_from_weeknum(get_weeknum())) . ' but their subscription is nearing its end.';
                    break;
                case 'paused':
                    echo ' is <strong>PAUSED</strong>. They will not receive a subscription for the duration of their pause. Please inspect the subscription details for more info.';
                    break;
                case 'inactive':
                    echo ' is <strong>INACTIVE</strong>. This user has no active subscriptions, would they like a new one?';
                    break;
                case 'future':
                    echo ' has a <strong>FUTURE</strong> subscription.';
                    break;
            }
        ?></p>
    </div>
    <a class="show-tool-tip grey delete icon-button right" href="<?php echo $Controller->page_url('edit'); ?>&delete=user&id=<?php echo $user->user_id; ?>">DELETE ALL SUBSCRIPTIONS</a>
</div> 
<?php

}

?>